package com.sky.controller.users;
import com.sky.dto.MedicinalPageQueryDTO;
import com.sky.entity.Medicinal;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.MedicinalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/medicinal")
@Api(tags = "中药材相关接口")
public class MedicinalController {
    @Autowired
    private MedicinalService medicinalService;
    @GetMapping("/getAll")
    @ApiOperation(value = "查询所有药材接口")
    public List<Medicinal> getAll(){
        List<Medicinal> medicinalList = medicinalService.medicinalList();
        return medicinalList;
    }

    @GetMapping("/page")
    @ApiOperation(value = "药材分页查询接口")
    public Result<PageResult> pageSelect(MedicinalPageQueryDTO medicinalPageQueryDTO){
        PageResult pageResult=medicinalService.pageQuery(medicinalPageQueryDTO);
        return Result.success(pageResult);
    }

}
